package org.nns.academy.certs;


import org.junit.jupiter.api.Test;

import java.io.FileInputStream;
import java.security.PublicKey;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;

public class ParseCert {

    public static final String CERT_PATH = "E:\\certs\\www.google.com\\public.cer";
    public static final String KEY_PATH = "E:\\certs\\certs.yangde.top\\server.pem";

    /**
     * 通过pem文件获取证书对象
     */
    @Test
    public void test2() throws Exception {
        CertificateFactory fact = CertificateFactory.getInstance("X.509");
        X509Certificate certificate = (X509Certificate) fact.generateCertificate(new FileInputStream(CERT_PATH));
        PublicKey publicKey = certificate.getPublicKey();
        System.out.println(publicKey);

    }
}
